package org.fatmansoft.teach.controllers;

import org.fatmansoft.teach.payload.request.DataRequest;
import org.fatmansoft.teach.payload.response.DataResponse;
import org.fatmansoft.teach.service.DailyActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.xml.crypto.Data;

@RestController
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping("/api/daily")
public class DailyActivityController {

    @Autowired
    DailyActivityService dailyActivityService;

    //增加日常活动
    @PostMapping("/saveActivity")
    public DataResponse insertDailyActivity(@Valid @RequestBody DataRequest dataRequest) {
        return dailyActivityService.saveActivity(dataRequest);
    }

    //删除日常活动
    @PostMapping("/deleteActivity")
    public DataResponse deleteDailyActivity(@Valid @RequestBody DataRequest dataRequest) {
        return dailyActivityService.deleteActivity(dataRequest);
    }

    //更新日常活动
    @PostMapping("/update")
    public DataResponse updateDailyActivity(@Valid @RequestBody DataRequest dataRequest) {
        return dailyActivityService.update(dataRequest);
    }

    //查找日常活动
    @PostMapping("/getDailyActivityInfo")
    public DataResponse findDailyActivity(@Valid @RequestBody DataRequest dataRequest) {
        return dailyActivityService.getDailyActivityInfo(dataRequest);
    }


    //插入学生日常活动(中间表
    @PostMapping("/insertStudentDaily")
    public DataResponse insertStudentDailyActivity(@Valid @RequestBody DataRequest dataRequest) {
        return dailyActivityService.insertPlus(dataRequest);
    }

    //删除学生日常活动(中间表
    @PostMapping("/deleteStudentDailyActivity")
    public DataResponse deleteStudentDailyActivity(@Valid @RequestBody DataRequest dataRequest) {
        return dailyActivityService.deleteStudentDailyActivity(dataRequest);
    }

    //查找学生日常活动
    @PostMapping("/getStudent")
    public DataResponse getStudentDailyActivity(@Valid @RequestBody DataRequest dataRequest) {
        return dailyActivityService.getDailyActivityByStudent(dataRequest);
    }

    @PostMapping("/getDailyActivityList")
    public DataResponse getDailyActivityByNameType(@Valid @RequestBody DataRequest dataRequest) {
        return dailyActivityService.findByNameType(dataRequest);
    }

    @PostMapping("/getStudentDailyActivityList")
    public DataResponse getStudentDailyActivityList(@Valid @RequestBody DataRequest dataRequest) {
        return dailyActivityService.getStudentDailyActivityList(dataRequest);
    }

    @PostMapping("/getStudentDailyActivityListByStudent")
    public DataResponse getStudentDailyActivityListByStudent(@Valid @RequestBody DataRequest dataRequest) {
        return dailyActivityService.getStudentDailyActivityListByStudent(dataRequest);
    }

    @PostMapping("/getStudentDailyActivityByStudentAndDaily")
    public DataResponse getStudentDailyActivityByStudentAndDaily(@Valid @RequestBody DataRequest dataRequest) {
        return dailyActivityService.getStudentDailyActivityByStudentAndDaily(dataRequest);
    }
}
